import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Test {


    public static void main2(String[] args) {
        Set<String> set = new TreeSet<>();   // treeSet底层是个TreeMap
        set.add("alibaba");
        set.add("tengxun");
        set.add("zijietiaodong");
        set.add("baidu");
        System.out.println(set);
    }

    public static void main(String[] args) {
        Map<String, Integer> treeMap = new TreeMap<>();  // 不能使用迭代器遍历
        treeMap.put("alibaba", 1);
        treeMap.put("tengxun", 2);
        treeMap.put("zijietiaodong", 3);
        treeMap.put("baidu", 4);
        System.out.println(treeMap);
        Set<Map.Entry<String, Integer>> entries = treeMap.entrySet();
        for (Map.Entry<String, Integer> x : entries) {
            System.out.println(x.getKey() + "" + x.getValue());
        }
    }
}
